//version as of 29 March
//21March Modified to take in a byte array before writing to nand
//20Mar2103 Merging of BobDNT200kMarch with Bob Main 
//Code for sensor read left in comments in case later use is desired.
//19mar cutting together with new lm303 choices
//
//15Mar2013 KAL merging of jacob's FlashLibraryTest and peter's BobDnt200


#include <Wire.h>
//#include "LSM303.h"

// inslude the SPI library:
#include "Flash.h"
#include <SPI.h>
#include <Serial.h>
#include <EEPROM.h>

Flash* nandFlash;

void setup() 
{
  Serial.begin(230400);
    
  nandFlash = new Flash();

  delay(1000);
}

void loop() 
{
  int byteCount = 0;
  
  while(1)
  {
     if (byteCount > 2000)
     {
       nandFlash->cacheToArray();
       byteCount = 0;
     }
     if (Serial.available()) 
     {
       byte in = Serial.read();
       nandFlash->writeBytes(&in,1);
       byteCount++;
     }
  }
}
